package pl.auction_search.command;

import java.util.LinkedList;
import java.util.List;

import pl.auction_search.model.ISearchResultModel;
import pl.auction_search.search.Result;

public abstract class ShowResultCommand implements IShowResultCommand {
	private static final long serialVersionUID = 1L;
	protected List<Result> results;
	protected ISearchResultModel<Result> model;

	public ShowResultCommand(ISearchResultModel<Result> model) {
		this.model = model;
	}

	@Override public void run() {
		for (Result result : results) {
			model.add(result);
		}
		refreshView();
	}

	public List<Result> getResults() {
		return results == null ? (results = new LinkedList<Result>()) : results;
	}

	public ShowResultCommand setResults(List<Result> results) {
		this.results = results;
		return this;
	}
}
